<?php
class Timer
{
	public $start;
	public $end;
	public $diff;
	
	public function __construct()
	{
		$this->start = $this->getTime();
	}
	
	public function end()
	{
		$this->end = $this->getTime();
		$this->diff =  $this->end - $this->start;
		return $this->diff;
	}
	
	public function getTime()
	{
		return microtime(true);
	}
	
	public static  function average($timers = array())
	{
		$diff = 0;
		$length = count($timers);
		foreach ($timers as  $timer)
		{
			$diff += $timer->diff;
		}
		return ($diff / $length);
	}
}
?>